package Review;

import java.util.Stack;


public class Test05 {

	public static void main(String[] args) {
	      ListNode head=new ListNode(1);  
	      ListNode p = head;
	      p.next = new ListNode(2);
	      p=p.next;
	      p.next = new ListNode(3);
	      p=p.next;
	      p.next = new ListNode(4);
	      printListNodeReversely(head);
	}
    public static void printListNodeReversely(ListNode head){
    	if(head == null)
    		return;
    	Stack<Integer> st = new Stack<Integer>();
    	while(head!=null){
    		st.push(head.value);
    		head = head.next;
    	}
    	while(!st.isEmpty()){
    		System.out.println(st.pop());
    	}
    }
}
